package org.example.listener;


import org.example.dao.DepartmentDao;
import org.example.dao.DictDao;
import org.example.dao.impl.DictDaoImpl;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.util.Map;

@WebListener()
public class ApplicationListener implements ServletContextListener {
    public ApplicationListener(){

    }

    public void contextInitialized(ServletContextEvent sce){
        /*
        * 读取字典表
        * */

        ServletContext application = sce.getServletContext();
        DictDao dictDao = DictDao.getInstance();
        Map<String,String> jobMap=dictDao.getJobType();
        application.setAttribute("jobMap",jobMap);
        DepartmentDao departDao = DepartmentDao.getInstance();
        Map<String,String> departMap=departDao.getDepartment();
        application.setAttribute("departMap",departMap);


    }

    public void contextDestroyed(ServletContextEvent sce){

    }



}
